qrCoderKax01.onFirefoxLoad = function(event) {
  document.getElementById("contentAreaContextMenu")
    .addEventListener("popupshowing", function (e){ qrCoderKax01.showFirefoxContextMenu(e); }, false);
};

qrCoderKax01.showFirefoxContextMenu = function(event) {
  //Set behaviour based on which item is selected.
  document.getElementById("context-qrCoderKax01").hidden = false;
  document.getElementById("context-qrCodeKax01-image").height = 120;
  document.getElementById("context-qrCodeKax01-image").width = 120;

  if (gContextMenu.onLink) {
    //Handle Link URI here.
    document.getElementById("context-qrCodeKax01-image").src = qrCoderKax01.getLinkAsQrCode(gContextMenu.linkURL);
    document.getElementById("context-qrCodeKax01-caption").label = "Link QR Code";
  } else if (gContextMenu.onImage) {
    //Handle image URI here.
    document.getElementById("context-qrCodeKax01-image").src = qrCoderKax01.getLinkAsQrCode(gContextMenu.imageURL);
    document.getElementById("context-qrCodeKax01-caption").label = "Image QR Code";
  } else {
    if (gContextMenu.isContentSelected) {
      document.getElementById("context-qrCodeKax01-image").src = qrCoderKax01.getLinkAsQrCode(content.getSelection().toString());
      document.getElementById("context-qrCodeKax01-caption").label = "Selection QR Code";
    } else {
      //Handle page URI here.
      document.getElementById("context-qrCodeKax01-image").src = qrCoderKax01.getLinkAsQrCode(window.content.location.href);
      document.getElementById("context-qrCodeKax01-caption").label = "Page QR Code";
    }
  }
};

window.addEventListener("load", function () { qrCoderKax01.onFirefoxLoad(); }, false);
